#include <REGX52.H>

void delay_ms(unsigned int ms)
{
    unsigned int i, j;
    for (i = 0; i < ms; i++)
    {
        for (j = 0; j < 123; j++)
            ;
    }
}

void main()
{
    int i;
    while(1)
    {
      P2 = ~(0x01);
      for(i=0;i<=7;i++)
      {
        P2= ~(0x01 << i);
        delay_ms(500);
        if(i==7)
        {
        P2=0x00;
        delay_ms(500);
        }
      }
    }
}